﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace web.website
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                      
            routes.MapRoute(
                "home", // Route name
                "", // URL with parameters
                new { controller = "home", action = "index" } // Parameter defaults
            );

            routes.MapRoute(
                "contact", // Route name
                "lien_he.ub", // URL with parameters
                new { controller = "home", action = "contact" } // Parameter defaults
            );

            routes.MapRoute(
                "sitemap", // Route name
                "sitemap", // URL with parameters
                new { controller = "home", action = "sitemap" } // Parameter defaults
            );

            routes.MapRoute(
                "product_tag", // Route name
                "san_pham_theo_chu_de/{tag}", // URL with parameters
                new { controller = "shop", action = "product_by_tag" } // Parameter defaults
            );

            routes.MapRoute(
                "page_static", // Route name
                "thong_tin_ubuy/{link}_{id}.ub", // URL with parameters
                new { controller = "pageStatic", action = "detail", id = UrlParameter.Optional } // Parameter defaults
            );
                      

            routes.MapRoute(
                "product_searh_ubuy", // Route name article detail
                "tim_kiem.ub", // URL for detail article
                new { controller = "shop", action = "product_search_basic", search = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "payment_method", // Route payment method
                 "phuong_thuc_thanh_toan.ub", // URL with parameters
                new { controller = "checkout", action = "payment_method" }
            );

            routes.MapRoute(
                "order_login", // Route payment method
                 "dang_nhap_thanh_toan.ub", // URL with parameters
                new { controller = "checkout", action = "order_login" }
            );

            routes.MapRoute(
                "payment_order", // Route payment method
                 "thong_tin_don_hang.ub", // URL with parameters
                new { controller = "checkout", action = "member_order" }
            );

            routes.MapRoute(
                "check_out_success", // Route payment method
                 "dat_hang_thanh_cong.ub", // URL with parameters
                new { controller = "checkout", action = "check_out_success" }
            );

            routes.MapRoute(
                "cart", // Route gio hang
                "gio_hang.ub", // URL with parameters
                new { controller = "shoppingCart", action = "cart" }
            );

            routes.MapRoute(
                "cartbox", // Route gio hang
                "gio_hang_box.ub", // URL with parameters
                new { controller = "shoppingCart", action = "cartbox" }
            );

            routes.MapRoute(
                "member_login", // Route login
                "dang_nhap.ub", // URL with parameters
                new { controller = "member", action = "member_login" }
            );

            routes.MapRoute(
                "member_register", // Route login
                "dang_ky.ub", // URL with parameters
                new { controller = "member", action = "member_register" }
            );

            routes.MapRoute(
                "CartMini", // Route login
                "shoppingCart/CartMini", // URL with parameters
                new { controller = "shoppingCart", action = "CartMini" }
            );

            routes.MapRoute(
                "main_menu_create", // Route login
                "pageLayoutClient/main_menu_create", // URL with parameters
                new { controller = "pageLayoutClient", action = "main_menu_create" }
            );

            routes.MapRoute(
               "member_change_password", // Route login
               "doi_mat_khau.ub", // URL with parameters
               new { controller = "member", action = "member_change_password" }
           );

            routes.MapRoute(
              "member_order_history", // Route login
              "danh_sach_don_hang.ub", // URL with parameters
              new { controller = "member", action = "member_order_history" }
          );

            routes.MapRoute(
               "member_forgot_password", // Route login
               "lay_lai_mat_khau.ub", // URL with parameters
               new { controller = "member", action = "member_forgot_password" }
           );

            routes.MapRoute(
                "member_logout", // Route name
                "thoat.ub", // URL with parameters
                new { controller = "member", action = "logout" }
            );

            routes.MapRoute(
                "member_management", // Route management
                "tai_khoan_ca_nhan.ub", // URL with parameters
                new { controller = "member", action = "member_management" }
            );

            routes.MapRoute(
                "member_infor_edit", // Route management
                "cap_nhat_thong_tin_tai_khoan.ub", // URL with parameters
                new { controller = "member", action = "member_infor_edit" }
            );

            routes.MapRoute(
                "article_list_all", // Route name article list for all article
                "tin_tuc.ub", // URL for list article
                new { controller = "article", action = "article_list" } // Parameter defaults
            );

            routes.MapRoute(
                "article_list", // Route name article list
                "{alias_category}_{cateId}.ub", // URL for list article
                new { controller = "article", action = "article_list", cateId = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "article_detail", // Route name article detail
                "{alias_category}/{alias_article}_{id}.ub", // URL for detail article
                new { controller = "article", action = "detail", id = UrlParameter.Optional, alias_cate = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "product_list", // Route name product list
                "{alias_cate_product}_{cateId}", // URL for list product
                new { controller = "shop", action = "product", cateId = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "product_list_all", // Route name product list for all product
                "san_pham", // URL for list product
                new { controller = "shop", action = "product" } // Parameter defaults
            );

            routes.MapRoute(
                "product_detail", // Route name product detail
                "{alias_cate_product}/{alias_pro}_{id}", // URL for detail article
                new { controller = "shop", action = "detail", id = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "home_metadata", // Route name
                "home/home_metadata", // URL with parameters
                new { controller = "home", action = "home_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "product_metadata", // Route name
                "shop/product_metadata", // URL with parameters
                new { controller = "shop", action = "product_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "product_detail_metadata", // Route name
                "shop/product_detail_metadata", // URL with parameters
                new { controller = "shop", action = "product_detail_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "product_tag_metadata", // Route name
                "shop/product_tag_metadata", // URL with parameters
                new { controller = "shop", action = "product_tag_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "article_list_metadata", // Route name
                "article/article_list_metadata", // URL with parameters
                new { controller = "article", action = "article_list_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "article_detail_metadata", // Route name
                "article/article_detail_metadata", // URL with parameters
                new { controller = "article", action = "article_detail_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "page_detail_metadata", // Route name
                "pageStatic/page_detail_metadata", // URL with parameters
                new { controller = "pageStatic", action = "page_detail_metadata" } // Parameter defaults
            );

            routes.MapRoute(
                "header_top", // Route name
                "pageLayoutClient/header_top", // URL with parameters
                new { controller = "pageLayoutClient", action = "header_top" } // Parameter defaults
            );

            routes.MapRoute(
                "shopping_guide", // Route name
                "pageLayoutClient/shopping_guide", // URL with parameters
                new { controller = "pageLayoutClient", action = "shopping_guide" } // Parameter defaults
            );

            routes.MapRoute(
                "page_detail", // Route name
                "pageStatic/page_detail", // URL with parameters
                new { controller = "pageStatic", action = "page_detail" } // Parameter defaults
            );

            routes.MapRoute(
                "create_order", // Route name
                "checkout/create_order", // URL with parameters
                new { controller = "checkout", action = "create_order" } // Parameter defaults
            );

            routes.MapRoute(
                "order_metadata", // Route name
                "checkout/order_metadata", // URL with parameters
                new { controller = "checkout", action = "order_metadata" } // Parameter defaults
            );

            routes.MapRoute(
               "default", // Route name article detail
               "{controller}/{action}", // URL for detail article
               new { controller = "", action = "" } // Parameter defaults
           );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }

    
}